package WaiBao;

import java.util.Arrays;

public class JiaHui {
    public static void main(String[] args) {
        String[] name = {"张宏伟(班长)","李霞鹏(体育委员)", "小李(学习委员)","郭小龙(文艺委员)", "郭敬明", "杨幂", "张翰", "张德发", "张珊", "丽景苑", "张三丰", "张无忌",
                "赵丽颖", "迪丽热巴", "城镇光", "李浩天", "张浩楠", "张金鹏", "李志豪", "姜维", "李道伟", "李艳杰", "张艳军", "王朋", "李混", "戴天理", "待天命", "张海鸥",
                "李芳芳", "贾慧(学生)"};//考生本人: 贾慧(学生)
        int[] age = {20,19, 19,20, 18, 20, 19, 20, 19, 19, 18, 18, 18, 20, 19, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 20, 21,20, 19, 20};//最后一位：考生年龄:20

        double[] tiger1 = {87, 90, 86, 78, 71, 67, 78, 89, 81, 80, 91, 81, 85, 76, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 88, 96};
        double[] tiger2 = {81, 88, 65, 90, 68, 67, 89, 64, 88, 77, 85, 72, 76, 85, 65, 75, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 84, 64, 80, 96};
        double[] tiger3 = {80, 67, 84, 85, 75, 64, 78, 69, 80, 80, 83, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 96};


        double hulu1;//代表每个学生的总分
        double hulu2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            hulu1 =tiger1[i] + tiger2[i] + tiger3[i];
//            hulu2= (hulu1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + hulu1);
//            System.out.println(name[i] + "的平均分为:" + hulu2);
//        }



        double youxiu1 = 0,youxiu2 = 0;
        double[] hula = new double[30];
//        for (int i = 0; i < 30; i++) {
//            youxiu1=tiger1[i] +tiger2[i] + tiger3[i];
//            youxiu2 = (youxiu1* 1.0) / 3;
//            hula[i] = youxiu2;
//        }
//
//        for (int i = 0; i < hula.length - 1; i++) {
//            for (int j = 0; j <hula.length - i - 1; j++) {
//                if (hula[j] <hula[j + 1]) {
//                    double tep = hula[j];
//                    hula[j] =hula[j + 1];
//                    hula[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(hula[i]);
//        }


        double shuben1 = 0, shuben2 = 0, shuben3 = 0;//计算每门课的平均分
        double ganbi1 = 0, ganbi2 = 0, ganbi3 = 0;//计算每门课标准差
        double dianxian1 = 0,dianxian2 = 0, dianxian3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < tiger1.length; i++) {
            he += tiger1[i];
        }
        shuben1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +shuben1);
        double Sum = 0;
        for (int i = 0; i < tiger2.length; i++) {
            Sum += tiger2[i];
        }
        shuben2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + shuben2);
        double sum = 0;
        for (int i = 0; i < tiger3.length; i++) {
            sum +=tiger3[i];
        }
        shuben3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + shuben3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < tiger1.length; i++) {
            c1 += (tiger1[i] - shuben1) * (tiger1[i] -shuben1);
        }
        ganbi1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" +ganbi1);
        for (int i = 0; i <tiger2.length; i++) {
            c2 += (tiger2[i] - shuben2) * (tiger2[i] -shuben2);
        }
        ganbi2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +ganbi2);

        for (int i = 0; i <tiger3.length; i++) {
            c3 += (tiger3[i] - shuben3) * (tiger3[i] - shuben3);
        }
        ganbi3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +ganbi3);
//////
        Arrays.sort(tiger1);
        Arrays.sort(tiger2);
        Arrays.sort(tiger3);
        dianxian1 = (tiger1[15] + tiger1[14]) * 1.0 / 2;
//        dianxian2 = (tiger2[15] +tiger2[14]) * 1.0 / 2;
//        dianxian3 = (tiger3[15] + tiger3[14]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" +  dianxian1);
//        System.out.println("农业设施设计与制造的中位数为:" +  dianxian2);
//        System.out.println("园艺植物设施栽培学的中位数为:" +  dianxian3);






    }
}
